package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.query.CommentQueryObject;
import cn.wolfcode.trip.base.service.ICommentService;
import cn.wolfcode.trip.base.service.IPraiseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/strategycomments")
public class StrategyCommentController {
    @Autowired
    private ICommentService commentService ;
    @Autowired
    private IPraiseService praiseService;
    /*
   获取这篇点评的的所有评论
   参数：
   资源：/strategycomments/{strategycommentId}/comments
   动作：GET
    */
    @GetMapping("/{strategycommentId}/comments")
    public Object getComments(CommentQueryObject qo){
        qo.setOrderBy("c.creatTime desc");
        return commentService.queryForLits(qo);
    }
    /*
   获取这篇点评的的所有评论的总数
   参数：
   资源：/strategycomments/{strategycommentId}/comments/total
   动作：GET
    */
    @GetMapping("/{strategycommentId}/comments/total")
    public Object getCommentsTotal(CommentQueryObject qo){

        return commentService.getCommentTotal(qo);
    }
    /*
   获取这篇点评的的所有评论的总数
   参数：
   资源：/strategycomments/{strategycommentId}/praise/total
   动作：GET
    */
    @GetMapping("/{strategycommentId}/praise/total")
    public Object getPraiseTotal(CommentQueryObject qo){

        return praiseService.getPraiseTotal(qo);
    }

}
